package common

import "encoding/json"

const (
	BitShareApp = 1 //分享app到朋友圈
)

// 货币类型
const (
	ACC_VALUE_ROOMCARD = 1 // 钻石
	ACC_VALUE_COIN     = 2 // 金币
	ACC_VALUE_SAFECOIN = 3 // 保险箱值
	ACC_VALUE_CASH     = 4 // 现金
)

//金流操作类型
const (
	ACCTRAN_OPER_TYPE_BuyCard      = 1  // 充值钻石
	ACCTRAN_OPER_TYPE_GIVE         = 2  // 赠送
	ACCTRAN_OPER_TYPE_GAME         = 3  // 游戏输赢
	ACCTRAN_OPER_TYPE_TASK         = 4  // 任务奖励
	ACCTRAN_OPER_TYPE_FEE          = 5  // 台费
	ACCTRAN_OPER_TYPE_LOGIN        = 6  // 登陆奖励
	ACCTRAN_OPER_TYPE_BANKRUPT     = 7  // 破产补助
	ACCTRAN_OPER_TYPE_MAIL         = 8  // 邮件领取
	ACCTRAN_OPER_TYPE_SAFEBOX      = 9  // 保险箱操作
	ACCTRAN_OPER_TYPE_PROOM        = 10 // 开房费
	ACCTRAN_OPER_TYPE_BACKSITE     = 11 // 后台赠送
	ACCTRAN_OPER_TYPE_SysGive      = 12 // 系统赠送钻石
	ACCTRAN_OPER_TYPE_SysChange    = 13 // 系统修改钻石
	ACCTRAN_OPER_TYPE_Exchange     = 14 // 兑换
	ACCTRAN_OPER_TYPE_Active       = 15 // 活动奖励
	ACCTRAN_OPER_TYPE_TransferCard = 16 // 回充钻石,把钻石从游戏帐号转移到合伙人系统里代理帐号

)

// 服务器状态
const (
	SERVER_STATE_NORMAL = 0 // 正常状态
	SERVER_STATE_REPAIR = 1 // 维护状态
)

// 服务器类型
const (
	SERVER_TYPE_LOBBY = 1 // 大厅服
	SERVER_TYPE_GAME  = 2 // 游戏服
)

// 大厅通信消息ID
const (
	PLAT_MSG_CHANGE_SAFEPWD       = 11 // 修改保险箱密码
	PLAT_MSG_KILL_PLAYER          = 12 // 踢出玩家
	PLAT_MSG_CHANGE_ACCVALUE      = 13 // 修改玩家数值
	PLAT_MSG_CREATE_PRIVATE_TABLE = 14 // 创建私人房
	PLAT_MSG_BROADCAST            = 15 // 广播消息
	PLAT_MSG_STOP_SERVER          = 16 // 停服维护
	PLAT_MSG_CLOSE_PLAYER_TABLE   = 17 // 关闭桌子
	PLAT_MSG_RELOAD_CONFIG        = 18 // 通知重载配置

)

//邮件消息类型
const (
	EmailTypeSys      = 1 //系统消息
	EmailTypeExchange = 2 //兑换通知
	EmailTypePay      = 3 //支付通知
	EmailTypeFriend   = 4 //好友邮件
)

// 系统常量
const (
	NationCode = 999999 //全国的区域代码
	OrderCode  = 9999   //默认排序

)

//操作日志模块,操作类型
const (
	LogPcUser     = 1  //用户模块
	LogGameConfig = 2  //游戏配置模块
	LogConfig     = 3  //配置相关
	LogPlayer     = 4  //玩家用户
	LogAgent      = 5  //代理用户
	LogFinance    = 6  //财务模块
	LogEmail      = 7  //邮件模块
	LogClub       = 8  //亲友圈
	LogHorse      = 9  //跑马灯
	LogOperation  = 9  //运营模块
	LogMenu       = 10 //菜单
	LogSystem     = 11 //系统配置
	LogRun        = 12 //运维模块
	LogLottery    = 13 //抽奖模块

	OpLogin  = 1 //登录
	OpLogout = 2 //登出
	OpDelete = 3 //删除
	OpNew    = 4 //新增
	OpUpdate = 5 //更新
)

//广播模块类型
const (
	ModuleClub   = "Club"   //亲友圈模块
	ModuleEmail  = "Email"  //邮件模块
	ModuleNotice = "Notice" //公告方面的
	ModuleHorse  = "Horse"  //跑马灯
	ModuleSys    = "System" //系统相关的
)

//广播操作类型
const (
	ActionExitClub              = "Exit"        //成员主动退出亲友圈
	ActionJoinClub              = "Join"        //加入亲友圈
	ActionJoinClubSuccess       = "JoinSuccess" //加入亲友圈成功
	ActionDeleteClubMember      = "Delete"      //亲友圈成员被删除
	ActionRejectClubMember      = "Reject"      //亲友圈成员加入被拒绝
	ActionBlockClubMember       = "Block"       //亲友圈成员被禁言
	ActionAgreeClubMemberJoin   = "Agree"       //同意亲友圈成员加入
	ActionCancelClubMemberBlock = "CancelBlock" //取消亲友圈成员黑名单
	ActionResumeClub            = "Resume"      //恢复亲友圈
	ActionDismissClub           = "Dismiss"     //解散亲友圈
	ActionFrozenClub            = "Frozen"      //冻结亲友圈
	ActionUpdateClub            = "Update"      //更新亲友圈
	ActionUpgradeClubMember     = "Upgrade"     //升级成管理员
	ActionDowngradeClubMember   = "Downgrade"   //降级普通成员
	ActionChangeHost            = "ChangeHost"  //更改俱乐部创建人

	ActionUpdateFloor       = "UpdateFloor"       //更新楼层
	ActionUpdateContestRule = "UpdateContestRule" //更新楼层比赛规则
	ActionAddFloor          = "AddFloor"          //添加楼层
	ActionDeleteFloor       = "DeleteFloor"       //添加楼层

	ActionUpdateScore = "UpdateScore" //更新积分

	ActionNewEmail          = "New"               //新邮件
	ActionUpdateGameNotice  = "UpdateGameNotice"  //游戏公告有更新
	ActionNewActivityNotice = "NewActivityNotice" //新活动公告
	ActionNewSystemNotice   = "NewSystemNotice"   //新系统公告
	ActionNewHorse          = "NewHorse"          //新系统公告

	ActionForceUpgrade   = "ForceUpgrade"   //强制玩家更新
	ActionForceSubmitLog = "ForceSubmitLog" //强制玩家提交日志
)

type BroadcastMsg struct {
	Module string      `json:"module"`
	Action string      `json:"action"`
	Value  interface{} `json:"value,omitempty"`
}

func GenBroadcastMsg(module, action string, value interface{}) string {
	msg := BroadcastMsg{Module: module, Action: action, Value: value}
	sendMsg, _ := json.Marshal(&msg)
	return string(sendMsg)
}
